<?php

class CompetitionController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        
        $comp = new Application_Model_Competition();
        $this->view->form = $comp->listCompetition();
        //var_dump($this->view->form);
    }

    public function addAction()
    {
        $ques = new Application_Model_Competition();
        
        $val= $ques->listCompetitionquestion($this->_request->getParam('id'));
       //var_dump($this->_request->getParams() ); die();
        $this->view->form = $val;
        if($this->_request->isPost())
        {
            $i=1;$count=0;$total=0;
            foreach ($val as $value) {
                $choosed = $this->_request->getParam('q'.$i);
                //var_dump($value);
                //if($this->_request->getParam("ques$i") == $value['Question'])
                //{
                    //echo "ques";
                
                if($value['correctAnswer']== $choosed)
                { //echo $value['correctAnswer']; echo $choosed;
                         $total++;
                   // $value['correctAnswer']= $this->_request->getParam("a$i");
                }
                   $count++; 
                   $i++;
            }
                
                //echo "count:".$count  ;
                //echo "<br>total:". $total;
                $this->view->val = $count;
                $this->view->total = $total;
                $this->render("result");
                
            }
        }
           
    }
//}





